//
//  NSString+Time.m
//  GeniusHelp_OC
//
//  Created by 8b410-2 on 16/11/29.
//  Copyright © 2016年 8b410-2. All rights reserved.
//

#import "NSString+Time.h"

@implementation NSString (Time)

+ (NSString *)getYearMonthDayByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd";
    return [formatter stringFromDate:date];
}
+ (NSString *)getHoursMinuteSecondByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"HH:mm:ss";
    return [formatter stringFromDate:date];
}
+ (NSString *)getHoursMinuteByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"HH:mm";
    return [formatter stringFromDate:date];
}
+ (NSString *)getYearByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy";
    return [formatter stringFromDate:date];
}
+ (NSString *)getMonthByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"MM";
    return [formatter stringFromDate:date];
}
+ (NSString *)getDayByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"dd";
    return [formatter stringFromDate:date];
}
+ (NSString *)getHoursByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"HH";
    return [formatter stringFromDate:date];
}
+ (NSString *)getMinuteByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"mm";
    return [formatter stringFromDate:date];
}
+ (NSString *)getSecondByTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:timeStamp];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"ss";
    return [formatter stringFromDate:date];
}

@end
